from PyQt6.QtWidgets import QWidget, QApplication

from utils.settings import DIALOG_GEO

WINDOW_SET = set()


# slot
def open_window(win):
    def inner():
        w = win()
        WINDOW_SET.add(w)
        w.show()

    return inner


def copy_to_clipboard(text):
    clipboard = QApplication.clipboard()
    clipboard.setText(text)


def qt_connect(signal, slot):
    signal.connect(slot)


class AbstractCustomDialog(QWidget):
    def __init__(self, parent=None):
        super(AbstractCustomDialog, self).__init__(parent)

        self.setGeometry(*DIALOG_GEO)

    def closeEvent(self, event):
        WINDOW_SET.remove(self)
